package com.zlx.guguanjia.mapper.provider;

import org.springframework.util.StringUtils;

import java.util.Map;

/**
 * @Author 周罗校
 * @Description
 * @ClassName ExamineSqlProvider
 * @date 2020.10.27 15:09:49
 * 该版权归周罗校所有，最终解释权以官方为准
 */
public class ExamineSqlProvider {

    public String selectPage(Map<String, Object> map) {
        StringBuilder sb = new StringBuilder();
        sb.append("SELECT " +
                "ex.*, " +
                "su.NAME user_name, " +
                "of.NAME office_name " +
                "FROM " +
                "examine ex, " +
                "sys_user su,  " +
                "sys_office of " +
                "WHERE " +
                "ex.del_flag = 0 ");
        if (map.containsKey("type")&&!StringUtils.isEmpty(map.get("type"))) {
            sb.append("AND ex.type = #{type} ");
        }
        if (map.containsKey("oid")&&!StringUtils.isEmpty(map.get("oid"))) {
            sb.append("AND su.office_id = #{oid} ");
        }
        if (map.containsKey("name")&&!StringUtils.isEmpty(map.get("name"))) {
            sb.append("AND su.NAME LIKE CONCAT( '%', #{name}, '%' )  ");
        }
        sb.append("AND ex.examine_user_id = su.id" +
                "  AND  su.office_id = of.id");
        return sb.toString();
    }
}
